module.exports = (param) => {
	var url = param.url;
	var data = param.data || {};
	var header = param.header || {};
	var method = param.method;
	
	if(method){
		method = method.toUpperCase(); // 小写转成大写
		if(method == "POST"){
			header = {"content-type":"application/x-www-form-urlencoded"};
		}
	}
	
	// 加载动画
	if(!param.hideLoading){
		uni.showLoading({title:"加载中..."})
	}
	
	uni.request({
	    url:url, //仅为示例，并非真实接口地址。
	    data:data,
	    header:header,
		method:method || "GET",
	    success: (res) => {
			if(res.statusCode && res.statusCode !== 200){
				uni.showModal({
					content:res.msg
				})
				return;
			}
			typeof param.success == "function" && param.success(res.data);
	    },
		fail: (err) => {
			uni.showModal({
				content: err.errMsg
			})
			typeof param.fail == "function" && param.fail(err);
		},
		complete: (data) => {
			console.log(data);
			uni.hideLoading();
			typeof param.complete == "function" && param.complete(data);
			return;
		}
	});
}